package org.opentcs.kcvehicle.communication.kc.service;

import static java.util.Objects.requireNonNull;

import jakarta.inject.Inject;
import java.util.HashMap;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2025/5/15 14:45
 */
public class Communications {
  private static HashMap<String, Communication> kcCommunicationHashMap = new HashMap<>();

  public static synchronized void setInstance(String name,Communication communication) {
    kcCommunicationHashMap.put(name, communication);
  }

  public static synchronized Communication getInstance(String name) {
    return kcCommunicationHashMap.get(name);
  }

  public static synchronized void removeInstance(String name) {
    kcCommunicationHashMap.remove(name);
  }

  public static synchronized boolean containsInstance(String name) {
    return kcCommunicationHashMap.containsKey(name);
  }

  public static synchronized void clearInstance() {
    kcCommunicationHashMap.clear();
  }
  public static synchronized int size() {
    return kcCommunicationHashMap.size();
  }
  public static synchronized HashMap<String, Communication> getKcCommunicationHashMap() {
    return kcCommunicationHashMap;
  }
}
